﻿namespace NIMServerApi.Commons
{
    public static class StringExtension
    {
        /// <summary>
        /// Jsons to object.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="str">The string.</param>
        /// <returns>T.</returns>
        public static T JsonToObject<T>(this string str)
        {
            if (string.IsNullOrEmpty(str))
                return default(T);
            return Newtonsoft.Json.JsonConvert.DeserializeObject<T>(str);
        }
    }
}